
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>win7x64下的redis安装与使用 - koal - 博客园</title>
<link type="text/css" rel="stylesheet" href="/bundles/blog-common.css?v=m_FXmwz3wxZoecUwNEK23PAzc-j9vbX_C6MblJ5ouMc1"/>
<link id="MainCss" type="text/css" rel="stylesheet" href="/skins/LessIsMoreRight/bundle-LessIsMoreRight.css?v=XnHJrmT6UJMtyGfeJjiTUm7BxKWcwdJrxKsGy7z3YZ81"/>
<link id="mobile-style" media="only screen and (max-width: 768px)" type="text/css" rel="stylesheet" href="/skins/LessIsMoreRight/bundle-LessIsMoreRight-mobile.css?v=qHJjANaihl7o1IFNmGDYMM2LY262zpYzn5es47eo-b81"/>
<link title="RSS" type="application/rss+xml" rel="alternate" href="http://www.cnblogs.com/koal/rss"/>
<link title="RSD" type="application/rsd+xml" rel="EditURI" href="http://www.cnblogs.com/koal/rsd.xml"/>
<link type="application/wlwmanifest+xml" rel="wlwmanifest" href="http://www.cnblogs.com/koal/wlwmanifest.xml"/>
<script src="//common.cnblogs.com/script/jquery.js" type="text/javascript"></script>  
<script type="text/javascript">var currentBlogApp = 'koal', cb_enable_mathjax=false;var isLogined=false;</script>
<script src="/bundles/blog-common.js?v=E1-LyrzANB2jbN9omtnpOHx3eU0Kt3DyislfhU0b5p81" type="text/javascript"></script>
</head>
<body>
<a name="top"></a>
<!--PageBeginHtml Block Begin-->
<script type="text/javascript" src="http://files.cnblogs.com/files/koal/shCore.js"></script>
<script type="text/javascript" src="http://files.cnblogs.com/files/koal/shAutoloader.js"></script>
<script type="text/javascript" src="http://files.cnblogs.com/files/koal/shBrushBash.js"></script>
<script type="text/javascript" src="http://files.cnblogs.com/files/koal/shBrushColdFusion.js"></script>
<script type="text/javascript" src="http://files.cnblogs.com/files/koal/shBrushCss.js"></script>
<script type="text/javascript" src="http://files.cnblogs.com/files/koal/shBrushDelphi.js"></script>
<script type="text/javascript" src="http://files.cnblogs.com/files/koal/shBrushJava.js"></script>
<script type="text/javascript" src="http://files.cnblogs.com/files/koal/shBrushJavaFX.js"></script>
<script type="text/javascript" src="http://files.cnblogs.com/files/koal/shBrus.js"></script>
<script type="text/javascript" src="http://files.cnblogs.com/files/koal/shBrushPerl.js"></script>
<script type="text/javascript" src="http://files.cnblogs.com/files/koal/shBrushPhp.js"></script>
<script type="text/javascript" src="http://files.cnblogs.com/files/koal/shBrushPython.js"></script>
<script type="text/javascript" src="http://files.cnblogs.com/files/koal/shBrushRuby.js"></script>
<script type="text/javascript" src="http://files.cnblogs.com/files/koal/shBrushSql.js"></script>
<script type="text/javascript" src="http://files.cnblogs.com/files/koal/shBrushXml.js"></script>
<link type="text/css" rel="stylesheet" href="http://files.cnblogs.com/files/koal/shCore.css"/>
<link type="text/css" rel="stylesheet" href="http://files.cnblogs.com/files/koal/shCoreDefault.css"/>
<script type="text/javascript">
    SyntaxHighlighter.config.strings.help = "";
    SyntaxHighlighter.config.strings.expandSource = "+ 查看代码";
    SyntaxHighlighter.all();
</script>
<!--PageBeginHtml Block End-->

<div id="home">
<div id="header">
	<div id="blogTitle">
		
<!--done-->
<div class="title"><a id="Header1_HeaderTitle" class="headermaintitle" href="http://www.cnblogs.com/koal/">koal的博客</a></div>
<div class="subtitle">记录学习过程中的点点滴滴，是喜欢、不是职业；记性不好，特别需要这么一个博客。</div>



		
	</div><!--end: blogTitle 博客的标题和副标题 -->
	<div id="navigator">
		
<ul id="navList">
<li id="nav_sitehome"><a id="blog_nav_sitehome" class="menu" href="http://www.cnblogs.com/">博客园</a></li>
<li id="nav_myhome"><a id="blog_nav_myhome" class="menu" href="http://www.cnblogs.com/koal/">首页</a></li>
<li id="nav_newpost"><a id="blog_nav_newpost" class="menu" rel="nofollow" href="https://i.cnblogs.com/EditPosts.aspx?opt=1">新随笔</a></li>
<li id="nav_contact"><a id="blog_nav_contact" class="menu" rel="nofollow" href="https://msg.cnblogs.com/send/koal">联系</a></li>
<li id="nav_rss">
<!----></li>
<li id="nav_admin"><a id="blog_nav_admin" class="menu" rel="nofollow" href="https://i.cnblogs.com/">管理</a></li>
</ul>

		<div class="blogStats">
			
			<div id="blog_stats">
<!--done-->
随笔-125&nbsp;
文章-0&nbsp;
评论-3&nbsp;
</div>
			
		</div><!--end: blogStats -->
	</div><!--end: navigator 博客导航栏 -->
</div><!--end: header 头部 -->
<div id="main">
	<div id="mainContent">
	<div class="forFlow">
		
<div id="post_detail">
<!--done-->
<div id="topics">
	<div class = "post">
		<h1 class = "postTitle">
			<a id="cb_post_title_url" class="postTitle2" href="http://www.cnblogs.com/koal/p/5484916.html">win7x64下的redis安装与使用</a>
		</h1>
		<div class="clear"></div>
		<div class="postBody">
			<div id="cnblogs_post_body"><p>先引用百度百科的一段话吧，具体可以到百科查看吧。</p>
<p>Redis是一个开源的使用ANSI&nbsp;C语言编写、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库，并提供多种语言的API。从2010年3月15日起，Redis的开发工作由VMware主持。从2013年5月开始，Redis的开发由Pivotal赞助。</p>
<p>官方下载地址：<a href="http://redis.io/download" target="_blank">http://redis.io/download</a>，不过官方没有64位的Windows下的可执行程序，目前有个开源的托管在github上, 地址：<a href="https://github.com/ServiceStack/redis-windows" target="_blank">https://github.com/ServiceStack/redis-windows</a>&nbsp;点击这个地方，下载文件并解压到自己的电脑目录下。</p>
<p>本文使用版本：<strong>redis64-3.0.501.zip</strong></p>
<p>解压后目录如下：</p>
<p><img src="http://images2015.cnblogs.com/blog/115145/201605/115145-20160512104220874-508264774.png" alt="" /></p>
<p>&nbsp;</p>
<table style="height: 225px; width: 605px; border: 0px solid #5eac53;" border="0" cellspacing="1" cellpadding="1">
<tbody>
<tr>
<td><span style="color: #008080;"><strong>文件名</strong></span></td>
<td><span style="color: #008080;"><strong>简要</strong></span></td>
</tr>
<tr>
<td>redis-benchmark.exe</td>
<td>基准测试</td>
</tr>
<tr>
<td>redis-check-aof.exe</td>
<td>aof</td>
</tr>
<tr>
<td>redischeck-dump.exe</td>
<td>dump</td>
</tr>
<tr>
<td>redis-cli.exe</td>
<td>客户端</td>
</tr>
<tr>
<td>redis-server.exe</td>
<td>服务器</td>
</tr>
<tr>
<td>redis.windows.conf</td>
<td>配置文件</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>然后编辑<strong>redis.windows.conf</strong>文件，我看网上有的教程说编辑里边<strong>maxheap &lt;bytes&gt;&nbsp;</strong>,但是3.x版本以后，修改的是 maxmemory&nbsp;<strong>&lt;bytes&gt;</strong>, bytes是字节，请自行换算，我这里改成<strong>maxmemory 1024000000</strong>。</p>
<p>其实这个地方可以不用设置，他描述上已经说了，redis会自动设置的。</p>
<p><img src="http://images2015.cnblogs.com/blog/115145/201605/115145-20160512104715234-1817307972.png" alt="" /></p>
<p>设置redis的密码：找到<strong># requirepass foobared</strong> 改为<strong> requirepass 我的密码 </strong>，本机测试可不设置。</p>
<p><img src="http://images2015.cnblogs.com/blog/115145/201605/115145-20160512110304655-524256208.png" alt="" /></p>
<p>&nbsp;</p>
<p>保存后打开redis的解压目录，shift+鼠标左键找到菜单上：<strong>在此处打开命令行窗口 或 </strong>自行运行cmd命令到此目录</p>
<p>命令如下：</p>
<div class="cnblogs_code">
<pre>redis<span style="color: #808080;">-</span>server.exe redis.windows.conf <span style="color: #008080;">--</span><span style="color: #008080;">maxmemory 200M</span></pre>
</div>
<p>其中--maxmemory 200M是选填的，如果你配置文件redis.windows.conf中配置，这个就可以省去，如果没配置，这个可以加也可以不加，你开心就好。</p>
<p><img src="http://images2015.cnblogs.com/blog/115145/201605/115145-20160512105249843-1874638663.png" alt="" /></p>
<p>当出现此界面的时候，说明启动成功，监听端口6379,然后让我们测试一下效果吧</p>
<p>重新打开一个DOS界面，效果如下：</p>
<p><img src="http://images2015.cnblogs.com/blog/115145/201605/115145-20160512105821343-1000684138.png" alt="" /></p>
<p>如果你设置了redis的密码，则需要在set之前执行auth 密码 命令，否则会提<strong>示(error) NOAUTH Authentication required.</strong></p>
<p><img src="http://images2015.cnblogs.com/blog/115145/201605/115145-20160512110957234-2001071191.png" alt="" /></p>
<p>最后说一下将redis加到Windows服务中。首先还是要启动redis服务器端，然后在运行redis客户端，然后通过Windows的service-install命令，输入</p>
<div class="cnblogs_code">
<pre>redis<span style="color: #808080;">-</span>server <span style="color: #008080;">--</span><span style="color: #008080;">service-install redis.windows.conf --loglevel verbose  </span></pre>
</div>
<p>以后就可以使用win的服务启动，而不需要每次都要打开一个DOS界面启动了。</p>
<p>推荐redis技术阅读：http://www.cnblogs.com/hoojo/p/4466024.html</p>
<p>推荐redis桌面客户端：http://www.oschina.net/p/redis-studio</p></div><div id="MySignature"></div>
<div class="clear"></div>
<div id="blog_post_info_block">
<div id="BlogPostCategory"></div>
<div id="EntryTag"></div>
<div id="blog_post_info">
</div>
<div class="clear"></div>
<div id="post_next_prev"></div>
</div>


		</div>
		<div class = "postDesc">posted @ <span id="post-date">2016-05-12 11:12</span> <a href='http://www.cnblogs.com/koal/'>koal</a> 阅读(<span id="post_view_count">...</span>) 评论(<span id="post_comment_count">...</span>)  <a href ="https://i.cnblogs.com/EditPosts.aspx?postid=5484916" rel="nofollow">编辑</a> <a href="#" onclick="AddToWz(5484916);return false;">收藏</a></div>
	</div>
	<script type="text/javascript">var allowComments=true,cb_blogId=67015,cb_entryId=5484916,cb_blogApp=currentBlogApp,cb_blogUserGuid='cf1cc4c9-b21a-df11-ba8f-001cf0cd104b',cb_entryCreatedDate='2016/5/12 11:12:00';loadViewCount(cb_entryId);</script>
	
</div><!--end: topics 文章、评论容器-->
</div><a name="!comments"></a><div id="blog-comments-placeholder"></div><script type="text/javascript">var commentManager = new blogCommentManager();commentManager.renderComments(0);</script>
<div id='comment_form' class='commentform'>
<a name='commentform'></a>
<div id='divCommentShow'></div>
<div id='comment_nav'><span id='span_refresh_tips'></span><a href='javascript:void(0);' onclick='return RefreshCommentList();' id='lnk_RefreshComments' runat='server' clientidmode='Static'>刷新评论</a><a href='#' onclick='return RefreshPage();'>刷新页面</a><a href='#top'>返回顶部</a></div>
<div id='comment_form_container'></div>
<div class='ad_text_commentbox' id='ad_text_under_commentbox'></div>
<div id='ad_t2'></div>
<div id='opt_under_post'></div>
<div id='cnblogs_c1' class='c_ad_block'></div>
<div id='under_post_news'></div>
<div id='cnblogs_c2' class='c_ad_block'></div>
<div id='under_post_kb'></div>
<div id='HistoryToday' class='c_ad_block'></div>
<script type='text/javascript'>
    fixPostBody();
    setTimeout(function () { incrementViewCount(cb_entryId); }, 50);
    deliverAdT2();
    deliverAdC1();
    deliverAdC2();    
    loadNewsAndKb();
    loadBlogSignature();
    LoadPostInfoBlock(cb_blogId, cb_entryId, cb_blogApp, cb_blogUserGuid);
    GetPrevNextPost(cb_entryId, cb_blogId, cb_entryCreatedDate);
    loadOptUnderPost();
    GetHistoryToday(cb_blogId, cb_blogApp, cb_entryCreatedDate);   
</script>
</div>


	</div><!--end: forFlow -->
	</div><!--end: mainContent 主体内容容器-->

	<div id="sideBar">
		<div id="sideBarMain">
			
			<div id="calendar"><div id="blog-calendar" style="display:none"></div><script type="text/javascript">loadBlogDefaultCalendar();</script></div>
			
			<div id="leftcontentcontainer">
				<div id="blog-sidecolumn"></div><script type="text/javascript">loadBlogSideColumn();</script>
			</div>
			
		</div><!--end: sideBarMain -->
	</div><!--end: sideBar 侧边栏容器 -->
	<div class="clear"></div>
	</div><!--end: main -->
	<div class="clear"></div>
	<div id="footer">
		
<!--done-->
Copyright &copy;2017 koal
	</div><!--end: footer -->
</div><!--end: home 自定义的最大容器 -->
</body>
</html>
